<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script>
</head>
<body>
<form action="test2.php">
    <input type="text" name="user" value="hongwei"/>
    <button id="submittest" type="button">button</button>
</form>

<script>
    $(function () {
        $("#submittest").click(function(){
            var data = {
                "user":$("input[name='user']").val(),
                "age":34
            };

            $.ajax({
                type : "post",
                url  : $("form").attr('action'),
                data: data,
                error: function(request) {
                    alert("服务器繁忙, 请联系管理员!");
                    return;
                },
                success: function(ret) {
                    console.log(ret);
                    if(data.length!=0){
                        //todo
                    }else{
                        //todo
                    }
                }
            })
        })

    })
</script>
</body>
</html>